home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
aviwi
/
avi_1.frm
next >
Wrap
Text File
|
1995-05-08
|
8KB
|
293 lines
VERSION 2.00
Begin Form Form1
BackColor = &H00C0C0C0&
BorderStyle = 3 'Fixed Double
Caption = ".AVI in Window Demo"
ClientHeight = 3150
ClientLeft = 1740
ClientTop = 1830
ClientWidth = 7485
Height = 3840
Left = 1680
LinkTopic = "Form1"
ScaleHeight = 3150
ScaleWidth = 7485
Top = 1200
Width = 7605
Begin CommandButton Command5
Caption = "Sound"
Height = 375
Left = 2640
TabIndex = 9
Top = 2280
Width = 615
End
Begin CommandButton Command4
Caption = "Stop"
Height = 375
Left = 2040
TabIndex = 8
Top = 2280
Width = 615
End
Begin CommandButton Command3
Caption = "Step"
Height = 375
Left = 1440
TabIndex = 7
Top = 2280
Width = 615
End
Begin CommandButton Command2
Caption = "Pause"
Height = 375
Left = 840
TabIndex = 6
Top = 2280
Width = 615
End
Begin CommandButton Command1
Caption = "Play"
Height = 375
Left = 240
TabIndex = 5
Top = 2280
Width = 615
End
Begin FileListBox File1
Height = 2370
Left = 5760
Pattern = "*.avi"
TabIndex = 3
Top = 120
Width = 1455
End
Begin DirListBox Dir1
Height = 1830
Left = 3960
TabIndex = 2
Top = 600
Width = 1455
End
Begin DriveListBox Drive1
Height = 315
Left = 3960
TabIndex = 1
Top = 120
Width = 1455
End
Begin PictureBox Picture1
BackColor = &H00808080&
Height = 1815
Left = 720
ScaleHeight = 1785
ScaleWidth = 2025
TabIndex = 0
Top = 240
Width = 2055
End
Begin Label Label1
Height = 255
Left = 1200
TabIndex = 10
Top = 2040
Width = 1215
End
Begin Label Label10
Height = 255
Left = 1200
TabIndex = 4
Top = 0
Width = 1215
End
Begin Menu about
Caption = "About..."
Begin Menu about1
Caption = "About .AVI File Viewer Demo "
WindowList = -1 'True
End
End
End
Sub about1_Click ()
CRLF$ = Chr$(13) + Chr$(10)
Msg$ = "Written by Rolf Mathison" + CRLF$ + "Compuserve 76376,3224" + CRLF$ + "This program demonstrates" + CRLF$ + "How to play .AVI files in a window" + CRLF$ + CRLF$ + "(Print out the form text & code for details)"
MsgBox (Msg$)
End Sub
Sub Command1_Click ()
' Close any open MCI devices
Action$ = "Close all"
i = mciExecute(Action$)
' Open the file with an alias (VID)
AliasName$ = "VID"
Action$ = "open " + mciFile + " alias " + AliasName$
i = mciExecute(Action$)
' Set the Focus to window where you want the video to play
' Picture1 GotFocus will return window "handle #" (hWnd) as
' HwndFrame
Picture1.SetFocus
' We have to put a delay here to allow for timing, or we may
' get the wrong hWnd #
WaitForEventsToFinish (50)
' Convert to string and set the window to use
HwndFr$ = CStr(HwndFrame)
Action$ = "window " + AliasName$ + " handle " + HwndFr$
i = mciExecute(Action$)
' Show the filename and mode then play the video
Label1.Caption = mciFileName
Label10.Caption = "Playing... "
Action$ = "Play VID"
i = mciExecute(Action$)
End Sub
Sub Command2_Click ()
' If we're not already paused, use the "Pause" command
If Paused = False Then
Action$ = "Pause " + AliasName$
Label10.Caption = "Paused... "
End If
' If we're paused use the "Play" command to resume
If Paused = True Then
Action$ = "Play " + AliasName$
Label10.Caption = "Playing... "
End If
' toggle the status of the "Paused" flag
If Paused = True Then
Paused = False
Else
Paused = True
End If
i = mciExecute(Action$)
End Sub
Sub Command3_Click ()
' Single step video forward by "1" frame
Action$ = "step " + AliasName$ + " by 1"
i = mciExecute(Action$)
' Change the mode label, SetFocus back to "Pause"
Label10.Caption = "Single Step..."
Command2.SetFocus
End Sub
Sub Command4_Click ()
' Stop the video, close the MCI device
Action$ = "Close all"
i = mciExecute(Action$)
' Clear Filename, show mode
Label1.Caption = ""
Label10.Caption = "Done... "
' SetFocus to Picture1 and blank out the video
Picture1.SetFocus
Picture1.BackColor = &H808080
' SetFocus back for the next file
File1.SetFocus
End Sub
Sub Command5_Click ()
' Toggle the sound on and off
If SoundStatus = True Then
Action$ = "setaudio " + AliasName$ + " off"
Label10.Caption = "Sound Off... "
Else
Action$ = "setaudio " + AliasName$ + " on"
Label10.Caption = "Sound On... "
End If
' toggle the status of the "SoundStatus" flag
If SoundStatus = True Then
SoundStatus = False
Else
SoundStatus = True
End If
i = mciExecute(Action$)
End Sub
Sub Dir1_Change ()
' Get the Directory
ChDir Form1.Dir1.List(Form1.Dir1.ListIndex)
File1.Path = CurDir$
File1.Refresh
End Sub
Sub Drive1_Change ()
' Get the disk drive
ChDrive Form1.Drive1.List(Form1.Drive1.ListIndex)
Dir1.Path = CurDir$
Dir1.Refresh
End Sub
Sub File1_Click ()
' Get the MCI filename
mciFile = File1.List(File1.ListIndex)
Label1.Caption = mciFile
' SetFocus to "Play"
Command1.SetFocus
End Sub
Sub File1_DblClick ()
' This just is a shortcut, it will start playing the video
' without pressing the "Play" key
' Close any open MCI devices
Action$ = "Close all"
i = mciExecute(Action$)
' Open up the file, using an alias (VID)
AliasName$ = "VID"
Action$ = "open " + mciFile + " alias " + AliasName$
i = mciExecute(Action$)
' Set focus to window where video is to play
Picture1.SetFocus
' We have to put a delay here to allow for timing, or we may
' get the wrong hWnd #
WaitForEventsToFinish (50)
' Picture1 GotFocus returns window "handle#" as HwndFrame
' Convert it to a string and set the window to use
HwndFr$ = CStr(HwndFrame)
Action$ = "window " + AliasName$ + " handle " + HwndFr$
i = mciExecute(Action$)
' Label the filename and mode
Label1.Caption = mciFile
Label10.Caption = "Playing... "
' Play the video
Action$ = "play " + AliasName$
i = mciExecute(Action$)
Command1.SetFocus
End Sub
Sub File1_GotFocus ()
SoundStatus = True
Paused = False
End Sub
Sub Form_Unload (Cancel As Integer)
' Close all files on exit
Action$ = "Close all"
i = mciExecute(Action$)
End Sub
Sub Picture1_GotFocus ()
' Get the hWnd "handle number" for the Picture1 window
' HwndFrame & GetFocus() are defined in Global.bas
HwndFrame = GetFocus()
End Sub